#include <iostream>
#include <functional>
#include <vector>

class EventSystem {
    std::vector<std::function<void(int)>> callbacks;

public:
    void registerCallback(std::function<void(int)> callback) {
        callbacks.push_back(callback);
    }

    void triggerEvent(int value) {
        for (auto& cb : callbacks) {
            cb(value);
        }
    }
};

void logEvent(int value) {
    std::cout << "Event logged: " << value << std::endl;
}

int main() {
    EventSystem system;
    
    // 注册普通函数
    system.registerCallback(logEvent);
    
    // 注册lambda表达式
    system.registerCallback([](int v) { 
        std::cout << "Lambda received: " << v << std::endl; 
    });
    
    // 使用bind注册
    auto boundFunc = std::bind(logEvent, std::placeholders::_1);
    system.registerCallback(boundFunc);

    // 触发事件
    system.triggerEvent(42);
    /* 输出:
       Event logged: 42
       Lambda received: 42
       Event logged: 42
    */

    return 0;
}